﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using olierFrm.Extensions.EString;

namespace olierFrm.MVC
{
    public class BusinessRoleFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string business = filterContext.RouteData.Values["SqlID"].ToString();
            string business2 = business;
            UserRole ur = new UserRole("^_^", business2);
            if (!ur.HavePower)
            {
                SmartPage.PostResult pr = new SmartPage.PostResult();
                pr.ToUrl = "/Account/Login";
                pr.Success = false;
                pr.Message = "您的权限不能执行此操作！";
                filterContext.Result = new EmptyResult();
                System.Web.HttpContext.Current.Response.Write(pr.ToJSON());
            }
            base.OnActionExecuting(filterContext);
        }
    }
}
